package cn.net.lwj.singledb.control;

import cn.net.lwj.common.control.BaseControl;
import cn.net.lwj.common.model.JsonResult;
import cn.net.lwj.singledb.service.JdbcService;
import cn.net.lwj.singledb.service.TestService;
import cn.net.lwj.singledb.service.impl.DemoServiceImpl;
import cn.net.lwj.singledb.service.impl.TransactionalServiceImpl;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoControl extends BaseControl {

    @Resource
    private TestService testService;

    @Resource
    private JdbcService jdbcService;

    @Resource
    private TransactionalServiceImpl transactionalService;

    @Resource
    private DemoServiceImpl demoService;



    @RequestMapping("/test")
    public JsonResult test(){
        //jdbcService.saveUser("lwj", "沙坪坝");

        //return JsonResult.responseSuccess("");
        return testService.test();
    }


    @RequestMapping("/rdjc")
    public JsonResult rdjc(){
        return testService.rdjcTest();
    }


    @RequestMapping("/tran")
    public JsonResult testTransactional(){
        //jdbcService.saveUser("lwj", "沙坪坝");

        //return JsonResult.responseSuccess("");
        //demoService.testNoTx();
        //transactionalService.testNoTx();
        //transactionalService.testTx();
        transactionalService.testMainHasTx();
        //transactionalService.testMainNoTx();
        return null;
    }
}
